/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package irsystem.scenario.method;

import java.util.List;

/**
 *
 * @author thoriq_r9
 */
public class NIAP {
    
    List<Integer> ret;
    List<Integer> rel;
    
    public NIAP(List<Integer> ret,List<Integer> rel){
        this.ret = ret;
        this.rel = rel;
    }
    
    public double process() {
        double avg_prec;
        double temp = 0;
        int iter = 0;   //total iterasi dokumen
        int count = 0;  //total relevan dari iterasi dokumen
        for (int i=0;i<ret.size();++i){
            for (int j=0;j<rel.size();++j){
				++iter;
                if (ret.get(i).equals(rel.get(j))){
                    ++count;
					temp += (count *1f / iter);
                    break;
                }
            }
        }
        avg_prec = temp*1f / ret.size();
        return avg_prec;        
    }
}
